package ui;

import java.awt.CardLayout;
import java.util.Iterator;

import javax.swing.JPanel;

import experiment.Dataset;
import experiment.ExperimentManager;
import experiment.ExperimentPhase;
import experiment.Question;

public class QuestionsPanel extends JPanel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4443211841927154089L;
	
	private ExperimentManager experimentManager;
	
	public QuestionsPanel(ExperimentManager experimentManager)
	{
		this.setExperimentManager(experimentManager);
		CardLayout layout = new CardLayout();
		this.setLayout(layout);
		for(Iterator<ExperimentPhase> itPhase = this.getExperimentManager().getExperiment().getPhasesIterator(); itPhase.hasNext();)
		{
			for(Iterator<Dataset> itDataset = itPhase.next().datasetOrder.datasets.iterator(); itDataset.hasNext();)
			{
				for(Iterator<Question> itQuestion = itDataset.next().questions.iterator(); itQuestion.hasNext();)
				{
					Question question = itQuestion.next();
					this.add(new BlankPanel());
					this.add(new QuestionPanel(question));
				}
			}
		}
		this.add(new EndPanel());
	}

	private void setExperimentManager(ExperimentManager experimentManager) {
		// TODO Auto-generated method stub
		this.experimentManager = experimentManager;
		
	}

	public ExperimentManager getExperimentManager() {
		return experimentManager;
	}
}
